package com.xbj.voa.controller;

import cn.hutool.core.date.DateUtil;
import com.auth0.jwt.JWT;
import com.xbj.voa.common.shiroAndJwt.JwtUtil;
import com.xbj.voa.common.utils.R;
import com.xbj.voa.service.CheckinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author: 木火
 * @create: 2024-01-23
 * @description:
 **/
@RequestMapping("/checkin")
@RestController
@Api("签到模块web接口")
public class CheckinController {
    @Resource
    private JwtUtil jwtUtil;

    @Resource
    private CheckinService checkinService;

    @GetMapping("/validCanCheckin")
    @ApiOperation("查看用户今天是否可以签到")
    public R validCanCheckin(@RequestHeader("token") String token){
        int userId = jwtUtil.getUserId(token);
        String result = checkinService.validCanCheckin(userId, DateUtil.today());
        return R.ok(result);
    }


}
